#function to allow changing of analysis_event_name config file
#function goes to config file path given, reads in the file and changes the analysis_event_name

import os
from {{ module.lower() }} import {{ module }}

def change_analysis_event(analysis_event,path_to_analysis_event):
	"""
	Changes the analysis event in the config file
	"""
	
	lines = []
	with open(path_to_analysis_event,"r") as fh:
		
		#read all lines in file
		lines = fh.readlines() 
		
		#change the second row
		lines[1] = analysis_event

	with open(path_to_analysis_event,"w") as fo:

		fo.write('\n'.join(lines))
			
# ask for the new analysis name
analysis_event = raw_input("\n Please enter analysis event name to use: ")


if analysis_event == "":
	print "\n No analysis_event entered. Current analysis_event: " + {{ module }}.get_current_analysis_event()
else:
	path_to_analysis_event = os.path.normpath({{ module }}.get_project_root()+"/config/analysis_event_name.csv")
	change_analysis_event(analysis_event,path_to_analysis_event)
	print "\n analysis_event changed to: " + analysis_event


